/**
 * Copying (c) Qixin Technoligies Co.,Ltd.2019-2029.all rights reserved.
 */

package com.example.service;

import lombok.extern.log4j.Log4j2;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.messaging.Message;
import org.springframework.messaging.core.MessagePostProcessor;
import org.springframework.stereotype.Service;

import javax.jms.Destination;
import javax.jms.TextMessage;

/**
 * 2、发布/订阅
 *
 * 创  建   时  间： 2020/5/17
 * 版           本: V1.0
 * 作           者: qixin
 * 版  权   所  有: 版权所有(C)2019-2029
 * 公           司: 深圳市七智星科技有限公司
 */
@Log4j2
@Service
public class PublisherService {
    @Autowired
    private JmsMessagingTemplate template;

    public void sendMsg(String topicName,String msg){
        log.info("topicName:{} msg:{}",topicName,msg);
        Destination destination = new ActiveMQTopic(topicName);
        template.convertAndSend(destination, msg);
    }
}
